<?php
/* *
 * 功能：注册
 * 日期：2016-02-17
 * 源码来自：资源e站（Zye.cc）
 * 资源分享：www.zye.cc
 */
?>
<?php
$mod='blank';
include("./includes/common.php");
if($_POST['type']=="reg"){
	$phone = isset($_POST['phone'])?(!$DB->get_row("select * from tell_users where phone='".daddslashes($_POST['phone'])."' limit 1")?daddslashes($_POST['phone']):exit("<script language='javascript'>alert('该手机号已存在！');history.go(-1);</script>")):exit("<script language='javascript'>alert('手机号不能为空！');history.go(-1);</script>");	
	$pass = isset($_POST['pass'])?daddslashes($_POST['pass']):exit("<script language='javascript'>alert('密码不能为空！');history.go(-1);</script>");
	$pass_ = isset($_POST['pass_'])?(daddslashes($_POST['pass_']==$pass)?NULL:exit("<script language='javascript'>alert('两次输入的密码不符合！');history.go(-1);</script>")):exit("<script language='javascript'>alert('密码不能为空！');history.go(-1);</script>");
	$qq = isset($_POST['qq'])?(!$DB->get_row("select * from tell_users where qq='".intval(daddslashes($_POST['qq']))."' limit 1")?intval(daddslashes($_POST['qq'])):exit("<script language='javascript'>alert('该QQ已被他人绑定！');history.go(-1);</script>")):exit("<script language='javascript'>alert('绑定QQ不能为空！');history.go(-1);</script>");
	$verify = $_SESSION['verify'];
	$code = isset($_POST['code'])?$_POST['code']:exit("<script language='javascript'>alert('验证码不能为空！');history.go(-1);</script>");
	if($code != $verify) exit("<script language='javascript'>alert('验证码不正确！');history.go(-1);</script>");
	$sql = "insert into tell_users (phone,pass,qq,regtime) values('$phone','$pass','$qq','".date("Y-m-d H:i:s")."')";
	if($DB->query($sql)){
		@header('Content-Type: text/html; charset=UTF-8');
		exit("<script language='javascript'>alert('注册成功！');window.location.href='./login.php';</script>");
		}else{
			@header('Content-Type: text/html; charset=UTF-8');
			exit("<script language='javascript'>alert('注册失败！".$DB->error()."');history.go(-1);</script>");
			}
	
	
}
$title='注册用户';
include './head.php';
?>
  <nav class="navbar navbar-fixed-top navbar-inverse">
    <div class="container">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
          <span class="sr-only">导航按钮</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="./">官方-改号宝</a>
      </div><!-- /.navbar-header -->
      <div id="navbar" class="collapse navbar-collapse">
        <ul class="nav navbar-nav navbar-right">
          <li>
            <a href="./login.php"><span class="glyphicon glyphicon-user"></span> 登录</a>
          </li>
          <li class="active">
            <a href="./reg.php"><span class="glyphicon glyphicon-user"></span> 注册</a>
          </li>
        </ul>
      </div><!-- /.navbar-collapse -->
    </div><!-- /.container -->
  </nav><!-- /.navbar -->
  <div class="container" style="padding-top:70px;">
    <div class="col-xs-12 col-sm-10 col-lg-8 center-block" style="float: none;">
      <div class="panel panel-primary">
        <div class="panel-heading"><h3 class="panel-title">注册用户</h3></div>
        <div class="panel-body">
          <form action="?" method="post" class="form-horizontal" role="form">
          <input type="hidden" name="type" value="reg" />
            <div class="input-group">
              <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
              <input type="text" name="phone" value="<?php echo @$_POST['user'];?>" class="form-control" placeholder="手机号" required/>
            </div><span>必须是自己的11位手机号，不然无法拨打电话。</span><br/><br/>
            <div class="input-group">
              <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
              <input type="password" name="pass" class="form-control" placeholder="密码" required/>
            </div><br/>
            <div class="input-group">
              <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
              <input type="password" name="pass_" class="form-control" placeholder="再输一遍密码" required/>
            </div><br/>
            <div class="input-group">
              <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
              <input type="text" name="qq" class="form-control" placeholder="绑定QQ号" required/>
            </div><br/>
            <div class="input-group">
              <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
              <input type="text" name="code" class="form-control" placeholder="验证码" required/>
            </div><br/>
                          <img title=点击刷新 src=vcode.php?"+Math.random()+" align=absbottom onclick=this.src='vcode.php?'+Math.random();></img>
            
            <div class="form-group">
              <div class="col-xs-12"><input type="submit" value="立即注册" class="btn btn-primary form-control"/></div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>